package com.icloud.article.boot.controller.admin;

import com.icloud.article.boot.dto.ArticleSettingsUpdateDto;
import com.icloud.article.boot.service.ArticleSettingsService;
import com.icloud.article.boot.vo.ArticleSettingsVo;
import com.icloud.common.core.api.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "后台动态设置接口")
@RequestMapping("/admin/settings")
@RequiredArgsConstructor
public class AdminArticleSettingsController {
    private final ArticleSettingsService articleSettingsService;

    @ApiOperation("查询")
    @PostMapping("/query")
    @ResponseBody
    public CommonResult<ArticleSettingsVo> query(){
        return CommonResult.success(articleSettingsService.get());
    }

    @ApiOperation("修改")
    @PostMapping("/update")
    @ResponseBody
    public CommonResult<Boolean> update(@Validated @RequestBody ArticleSettingsUpdateDto dto){
        return CommonResult.success(articleSettingsService.update(dto));
    }
}
